package cn.mothin.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import cn.mothin.entity.FunctionModule;
import cn.mothin.frame.core.base.BaseDao;

@Repository("88bb01e3-3c89-4ceb-a4c3-42a15517d775")
public class FunctionModuleDao extends BaseDao<FunctionModule> {
	public List<FunctionModule> findSubFunctionModuleListByModuleId(
			String moduleId) {
		String sql = "SELECT * FROM function_module WHERE parentId = ? ORDER BY name";
		return query(sql, moduleId);
	}

	// 2013-05-24
	public List<FunctionModule> findSubFunctionModuleListByModuleId(
			String moduleId, String roleId) {
		String sql = "SELECT * FROM function_module WHERE parentId=? AND id IN (SELECT moduleItemId FROM role_module_permission WHERE targetId = ?) ORDER BY name";
		return query(sql, moduleId, roleId);
	}
}
